import {reactive, ref, watch} from "vue";
import useApi, {type SysRole} from "@/views/sys/api/SysRoleApi";
import {useQueryTable} from "@/core/common/hooks/TableHooks";

/**
 * @Author: wangjian
 * 656876071@qq.com
 * @Date: 2024-08-12 16:05:34
 * @LastEditTime: 2024-09-19 10:33:14
 * @FilePath: src/views/sys/role/Hooks.ts
 * @Description:
 */
export const useEntrance = () => {

    const params = reactive<object>({})

    const columns: Array<any> = [
        {
            title: '角色名称',
            dataIndex: 'roleName',
        },
        {
            title: '角色编码',
            dataIndex: 'roleCode',
        },
        {
            title: '排序',
            dataIndex: 'sortNum',
        },
        {
            title: '数据权限',
            dataIndex: 'dataScope',
        },
        {
            title: '备注',
            dataIndex: 'remark',
        },
        {
            title: '创建时间',
            dataIndex: 'createdTime',
        },
        {
            title: '操作',
            dataIndex: 'operate',
        }
    ]
    const {getPage, deleteById} = useApi()

    const queryTable = useQueryTable(getPage, deleteById, params)

    return {
        params,
        columns,
        ...queryTable
    }
}
import {useSimpleForm} from "@/core/common/hooks/FormHooks";
import {type SysMenuTree} from "@/views/sys/api/SysMenuApi";

export const useForm = (callback: Function) => {
    const {add, update, getById} = useApi()
    const PRIMARY_KEY = "roleId"

    const form = ref<SysRole>({})

    const simpleForm = useSimpleForm(form, PRIMARY_KEY, add, update, getById, callback)

    const menuTree = ref<SysMenuTree[]>([])


    return {
        form,
        ...simpleForm,
        menuTree
    }
}